﻿@{
    ViewBag.Title = "查询";
}

<link href="~/Content/pageinit.css" rel="stylesheet" />
<div class="row">
    <div class="col-md-8">
        <div class="panel panel-default">
            <div class="panel-heading" id="TotalSale"></div>
            <div class="panel-body table-responsive">

            </div>
        </div>


    </div>
    <div class="col-md-4">

        <div class="panel panel-warning">
            <div class="panel-heading">交班列表</div>
            <div class="panel-body table-responsive">
                <table class="table table-condensed ">
                    <thead class="bg-success">
                        <tr><td>交班时间</td><td>交班人</td><td>班次</td></tr>
                    </thead>
                    <tbody id="Checkout_List"></tbody>
                </table>
                <hr />
                <!------page-------->
                <div class="page">
                    <div id="Pagination" class="meneame"></div>
                </div>
            </div>
        </div>



    </div>
</div>
<script src="~/Scripts/pagination.js"></script>
<script type="text/javascript">
    $(function () {
        $.ajax({
            type: "POST",
            url: "Query/Checkout_List_TotalPage",
            data: "",
            success: function (msg) {
                //  $("#TotalSale").html("总的销售额：" + msg.TotalSale);

                var pageIndex = 0;     //页面索引初始值
                var pageSize = 10;     //每页显示条数初始化，修改显示条数，修改这里即可

                InitTable(0);    //Load事件，初始化表格数据，页面索引为0（第一页）
                //分页，PageCount是总条目数，这是必选参数，其它参数都是可选
                $("#Pagination").pagination(msg, {
                    callback: PageCallback,  //PageCallback() 为翻页调用次函数。
                    prev_text: "« 上一页",
                    next_text: "下一页 »",
                    items_per_page: pageSize,
                    num_edge_entries: 2,       //两侧首尾分页条目数
                    num_display_entries: 6,    //连续分页主体部分分页条目数
                    current_page: pageIndex   //当前页索引
                });
                //翻页调用
                function PageCallback(index, jq) {

                    InitTable(index);
                }
                //请求分页数据开始
                function InitTable(pageIndex) {

                    $.ajax({
                        type: "POST",
                        dataType: "text",
                        url: 'Query/CheckoutList',      //提交到一般处理程序请求数据
                        data: "pageIndex=" + (pageIndex) + "&pageSize=" + pageSize,          //提交两个参数：pageIndex(页面索引)，pageSize(显示条数)
                        success: function (msg) {


                            //var persons = JSON.parse(msg);
                            var person = JSON.parse(msg);
                            var data = { "persons": person };
                     
                            $("#Checkout_List").html(Mustache.render("{{#persons}}<tr><td><a href='' onclick='Checkoutdetail({{CheckoutID}})'>{{CheckoutTime}}</a></td><td>{{CheckoutUserName}}</td><td>{{ShiftName}}</td></tr>{{/persons}}", data));



                        }
                    });

                }
                //请求分页数据结束
            }
        })
    });

    function Checkoutdetail(ID)
    {
        alert(ID);
    }
</script>